Home:ALL Converter>Passing id in URL to a modal

Passing id in URL to a modal

Ask Time:2020-02-24T01:15:35         Author:mayales

Json Formatter

I have a modal with an ID called modal_act_cat so I have anohter modal with a table. I want to pass the id from the table to the modal by clicking the field. My line code to go to the modal is (which opens the modal but with the fields empty):

echo "<tr><td><a href='#modal_act_cat name='cat_nombre_id'>" . $row['cat_nombre_id'] . "</a></td>

but if I add parameters to the URL in href, the modal does not show.

echo "<tr><td><a href='#modal_act_cat?cat_nombre_id=" . $row['cat_nombre_id'] . "' name='cat_nombre_id'>" . $row['cat_nombre_id'] . "</a></td>

See my modal below that I'm trying to get the cat_nombre_id to show the results.

  <div class="modal_container" id="modal_act_cat">
    <div class="modal">
      <a href="index.php" class="close">+</a>
      <span class="modal_heading">Actualizar categoría</span>
      <a href="#buscar_cat" class="logo">
        <i class="icon ion-md-search"></i>
      </a>
      <form class="form_crear_cat" action="crear_cat.php" method="POST">
        <?php
        require("conn.php");
        if(isset($_GET['cat_nombre_id'])){
          $cat_nombre_id = $_GET['cat_nombre_id'];
          $query = "SELECT * FROM categorias WHERE cat_nombre_id = '$cat_nombre_id'";
          $result = mysqli_query($conn, $query);
          while($row = mysqli_fetch_array($result)){
            ?>
            <input type="text" id="cc1" name="cat_nombre_id" value="" placeholder="Nombre de la Categoría" required><?php echo $row['cat_nombre_id']; ?></input>
            <input type="text" name="supCat_nombre_id" value="" placeholder="Nombre de la Super Categoría" required><?php echo $row['supCat_nombre_id']; ?></input>
            <textarea name="cat_descripcion" rows="3" placeholder="Descripción de la Categoría"><?php echo $row['cat_descripcion']; ?></textarea>
            <?php
          }
        }
        ?>
      </form>
    </div>
  </div>

I appreciate your suggestions.

Author:mayales,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/60364772/passing-id-in-url-to-a-modal
yy